//
//  homeViewController.swift
//  股票框架
//
//  Created by 李小骥 on 2017/9/28.
//  Copyright © 2017年 李小骥. All rights reserved.887007
//http://xy.cctvzxjy.com/Index/index/openid/oTCmj1dod0ECAyzDhw3JaLrnPS5A/wx_name/http%3A%2F%2Fwx.qlogo.cn%2Fmmopen%2Fvi_32%2FPiajxSqBRaEL0kgKrav2ehaxA1IhicneUhpvpRLd5iazOibPrOxjXCynfq8ibhKkkaty7VBtyAKztvlCK2RkbiaQKicJA%2F0/code/%E8%80%81++%E5%B1%B1%E5%B1%AF%E5%AD%90
//1467

import UIKit
import WebKit
class homeViewController: DKSWebViewController {
    
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

//        updateUrl()
        
    }
    override func viewDidLoad() {
//  利用已知token和 uuid 去登录
//        以下代码测试图片请求下载可以成功！
//        weak var weakSelf:homeViewController? = self
//        Utils.AlamofireAsynchronousGETUserInfo(uuid: "1583") { (result) in
//            let imv = UIImageView(image: result)
//            imv.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
//            weakSelf?.view.addSubview(imv)
//        }
        
        
        super.viewDidLoad()
//        WKWebView测试
//        self.automaticallyAdjustsScrollViewInsets = false
//        //测试 1030
//        let wkWebView = WebView()
//        var config = WkwebViewConfig()
//        config.isShowScrollIndicator = false
//        config.isProgressHidden = false
//        wkWebView.frame = CGRect(x: 10, y: 0, width: view.frame.size.width, height: view.frame.size.height - 200)
//        view.addSubview(wkWebView)
//        // 加载普通URL
//        config.scriptMessageHandlerArray = ["valueName"];
//        wkWebView.webConfig = config
//        wkWebView.delegate = self
//
//        if (lCode != nil && lCode?.userID != ""){
//            let uuid = lCode!.userID
//            wkWebView.webloadType(self, .URLString(url: "http://xy.cctvzxjy.com/Index/index/s/1/uuid/\(uuid)"))
//
//        }else{
//            wkWebView.webloadType(self, .URLString(url: "http://xy.cctvzxjy.com/Index/index/s/1/uuid/-1"))
////            wkWebView.webloadType(self, .HTMLName(name: "test"))
//
//        }
        
        
        
//        basicUrl = "http://xy.cctvzxjy.com/Index/index/s/1"
//        updateUrl()
        navigationController?.navigationBar.isTranslucent = false
//        var url = (newUrl == "") ? basicUrl : newUrl
//        var url = "http://xy.cctvzxjy.com/Index/index/s/1"
//        取到最后的部分，然后替换浪线为/，最后把
//        原地址：http://xy.cctvzxjy.com/Register/register/url/Bunch~watch~id~74
//        转换结果：http://xy.cctvzxjy.com/Bunch/watch/id/74/uuid/1467
//        算法：http://xy.cctvzxjy.com/+（原地址最后一个/后面的内容，把~替换成/）+uuid/1467
        
//        print(url)

//        let wv = UIWebView(frame: self.view.bounds)
//        self.view.addSubview(wv)
//        let url = URL(string: "http://xy.cctvzxjy.com/Index/index/s/1")
//        let request = URLRequest(url: url!)
//        wv.loadRequest(request)
        
        //测试用登录跳转 button
//        let button = UIButton(frame: CGRect(x: 60, y: 60, width: 60, height: 60))
//        button.backgroundColor = .red
//        button.addTarget(self, action: #selector(jumptologin), for: .touchUpInside)
//        self.view.addSubview(button)
//        print(Bundle.main.loadNibNamed("StockDetailHeadTopView", owner: self, options: nil))
        // Do any additional setup after loading the view.
    }
    
//    func webViewUserContentController(_ scriptMessageHandlerArray: [String], didReceive message: WKScriptMessage) {
//        print(message.body)
//    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //测试跳转用
    @objc func jumptologin(){
        let lgvc = StockDetailViewController1(nibName: "StockDetailViewController", bundle: Bundle.main)
        self.navigationController?.pushViewController(lgvc, animated: true)
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
//WKWebView测试
//extension homeViewController:WKWebViewDelegate{
//
//    func webViewUserContentController(_ scriptMessageHandlerArray: [String], didReceive message: WKScriptMessage) {
//        print(message.body)
//
//    }
//
//}

